package au.com.evoCoach.dao;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import au.com.evoCoach.domain.Coach;

@Repository
public class CoachDAO extends BaseDAO {

	public CoachDAO() {
		super(Coach.class);
	}
	
	public Coach authenticate(String coachName, String password) {
		String sql = "from Coach where name = :coachName and password = :password";
		Query query = getSession().createQuery(sql);
		query.setParameter("password", password);
		query.setParameter("coachName", coachName);
		
       	return (Coach) query.uniqueResult();
	}
	
    public Coach getCoach(String coachName) {
        String sql = "from Coach";
        Query query = getSession().createQuery(sql);
        query.setParameter("coachName", coachName);
        
        return (Coach) query.uniqueResult();
    }	
	
}
